Skip to main content

Why you should learn VIM

· 6 min read
Marcel Scherzer

Watch on YouTube

Watch "Why learn GIT" on YouTube.

  • 2:04 - How to get started with VIM.
  • 2:44 - Insert Mode. (make vim act like nano)
  • 3:40 - Getting back to normal
  • 4:09 - Console Mode
  • 5:00 - Quitting VIM
  • 6:10 - Quickly change the text inside quotes
  • 7:15 - Saving your changes.

Introduction

The motivation to write this article is to encourage you to add an efficiency skill to your skill set that will benefit you throughout your entire career as a developer. Let’s set a scene to get started.

Imagine a pleasant Sunday afternoon at home and you are trying to help someone in your family be more efficient by encouraging them to learn how to “copy & paste” with the keyboard.

Your protégé reciprocates with: “I don’t want to remember that “ctrl + v” pastes text, it makes no sense to press V for pasting, it’s too hard for my fingers, and why would I want to bother remembering that? Look, it’s easier to simply copy and paste from the menu with the mouse.”

Knowing what you know about working on computers; what’s going through your head as you hear that?

Right, I think the same thing when developers list their reasons for not wanting to learn VIM commands in their favourite IDE.

You can lead a horse to water, but you can’t make it drink. The phrase sits in the back of my mind when I introduce Developers to the idea of using VIM to navigate text in their favourite IDE. Why the resistance? Follow me to the water, you may want to take a drink.

Leading you to water.

If you are doing any kind of serious coding, you know you are using an Integrated Development Environment (IDE). And you know you have installed a bunch of IDE plugins to improve your workflow.

Yet there is this one plugin you’re avoiding. It exists in some form or another for all major IDEs. It has over 3.5 million installs just for VS-Code, and top ratings to boot. What’s Up? Why would you not want to learn a productivity skill that will benefit you throughout your entire career, has stood the test of time and is highly regarded by millions of software engineers? “Can’t be bothered,” you say.

Think about this. As we transition from hobbyist to professional developer, our coding tends to skew toward refactoring and debugging. That is, as professionals we tend to spend more time navigating around and editing existing source code and configuration files than we do creating new code.

Therefore, it makes sense to invest in skills that afford us the ability to remain focused when navigating and editing existing code, the cherry on top if we can do so while satisfying our inner geek.

VIM is an editor. However, VIM is also a paradigm for working with source code that you can integrate into your IDE. It is this last part that you should consider when you hear developers encourage you to learn VIM.

VIM is a beast and the possibilities for customisations to suit your specific workflow are endless.

The awesome news is that it is quick and easy to integrate some useful VIM commands into your workflow. Even if you just adopt the basics you are going to be rewarded, just as you were when you committed “copy and paste” using the keyboard to muscle memory.

Let’s quickly have a look at a proven approach to adopting the fundamentals of VIM so you can get started today.

Getting started on the road to greatness.

Typically, the biggest hurdle when adopting VIM is understanding the “MODES” paradigm.

VIM acknowledges that working on existing code and writing new code can be done more efficiently when the UI can be optimised for each of these two tasks. As such VIM offers different modes of operation suitable for the task at hand.

The two important modes are “normal” mode for moving around and making small changes and “insert” mode for writing new code and making big changes. If we relate this back to Nano or your IDE, then “insert” mode is the only mode you have.

Enabling a VIM plugin in your IDE then adds extra modes, such as “normal” mode for efficient navigation.

The other major feature to understand is Vim’s “console”. The console functions much like any command-line interface in which you can issue your commands. You use the console to load files, write files, get help, quit and many other functions.

Let’s have a quick walkthrough of the things you need to know to replace Nano with VIM so you can start developing this skill set.

Replace Nano with Vim

  • Whenever you would type “nano” to edit/create a file start typing “vim” instead.
  • Remember “nano” only has “insert” mode.
  • Vim has many modes and starts in “normal” mode.
  • To put Vim into “insert” mode press “i” (eye). In the bottom left Vim will show “insert” to show you are in “insert” mode. You can now use Vim like nano to edit text until you are ready to save or exit.
  • To exit any mode and to get back to “normal” mode press the “ESC” key.
  • To save and or quit use the vim console. To open the console dialogue press “:”.
  • There will be a prompt at the bottom of the screen for issuing commands. w (writes changes to disk), q (quits). Commands can often be combined for example typing “wq” writes changes and quits.
  • If you want help on any command or keyboard short cut type “help” followed by the key or command.

The above is all you need to know to replace “nano” with VIM. You are now ready to start learning VIM. I suggest starting with the inbuilt VIM tutorial. Instead of vim type “vimtutor” to launch the tutorial. You can follow that up with a game of “vim adventures”.

In follow up articles I will start to introduce you to the VIM basics that translate well to your IDE.

Before I leave you, below I have outlined a learning pathway to develop your VIM skills. Drink UP 🤘


VIM Learning Pathway

Instead of jumping in feet first by installing a VIM plugin into your IDE, I would suggest you follow the following progression to avoid frustration while you build up your muscle memory.

  1. The VIM editor will be your Training Ground. Stop using Nano.
  2. Learn to use VIM like a simple text editor. Load, Save, Edit, Quit.
  3. Learn basic commands.
  4. Do the vim tutorial, play vim adventures.
  5. Activate the VIM plugin in your IDE. Gradually try adding more commands to your workflow